package com.lzx.makeFriend.controller.web;

import com.lzx.common.utils.R;
import com.lzx.makeFriend.entity.Friend;
import com.lzx.makeFriend.service.FriendService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/makeFriend/friend/web")
public class WebFriendController {
    @Resource
    private FriendService friendService;

    //获取当前用户的好友列表
    @GetMapping("/getUserFriendList/{userId}")
    public R getUserFriendList(@PathVariable Long userId){
        return friendService.getUserFriendList(userId);
    }

    //当前用户同意或拒绝好友申请
    @PutMapping("/agreeOrRejectFriendApply/{userId}/{friendId}/{type}")
    public R agreeOrRejectFriendApply(@PathVariable Long userId, @PathVariable Long friendId, @PathVariable String type) {
        return friendService.agreeOrRejectFriendApply(userId, friendId, type);
    }

    //获取当前用户的好友申请列表
    @GetMapping("/getUserFriendApplyList/{userId}")
    public R getUserFriendApplyList(@PathVariable Long userId) {
        return friendService.getUserFriendApplyList(userId);
    }

    //申请添加好友
    @PostMapping("/applyFriend")
    public R applyFriend(@RequestBody Friend friend) {
        return friendService.applyFriend(friend);
    }
}
